import Types from '../actionTypes';
import {
  getInstructionLibraryData,
  getInstructionSingle
} from '../../api';


const GET_INSRUCTIONLIBRARY_DATA = (page = 1, page_size = 10, search) => {

  return new Promise((resolve, reject) => {
    getInstructionLibraryData(page, page_size, search)
      .then(res => {
        resolve({
          type: Types.GET_INSRUCTIONLIBRARY_DATA,
          data: res
        });
      })
      .catch(err => {
        console.log(err);
      });
  });
};

const INSRUCTION_SINGLE_DATA = params => {
  console.log(params);
  return new Promise((resolve, reject) => {
    getInstructionSingle(params)
      .then(res => {
        resolve({
          type: Types.INSRUCTION_SINGLE_DATA,
          data: res.data
        });
      })
      .catch(err => {
        console.log(err);
      });
  });
};

export default {
  GET_INSRUCTIONLIBRARY_DATA,
  INSRUCTION_SINGLE_DATA
};
